<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<%@ page contentType="text/html; charset=utf-8"%>
	<%@ include file="/commons/taglibs.jsp"%>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>我的信息终端列表</title>

		<%@ include file="/commons/css_js_head.jsp"%>
<script type="text/javascript">
//复写Url
doListUrl = "${ctx }/base/userMachineTypeAction!doMyMachineTypeList.ts";
doSaveUrl = "${ctx }/base/typeAuditAction!doSave.ts" 


//删除
function doDel(pkId) {
	var _form = document.forms[0];
	if (doDelUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}
	_form.action = doDelUrl + "&theId=" + pkId;
	_form.submit();
}
//关闭小窗口
function onCancel()
{
	closeWindow();
}
function closeWindow()
{
	self.parent.tb_remove();
}

 //批量选择
 function checkAll(check,me){   
    // 首先获得所有checkbox集合  
    var names = document.getElementsByName(check); 
    
    var status=me.checked;  
    for(var i=0;i<names.length;i++){   
        if(status==true){           
		   names[i].checked=true;}
		else{
		    names[i].checked=false;
		}   
    }   
}

//保存已选择信息终端类型ID
//选择要保存的应用的asid
function doSave(){


	if (doSaveUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}
    var nid="";
	var objs = document.getElementsByName("checkbox");
	for(var i=0; i<objs.length; i++) {
		if(objs[i].checked==true){
			nid=nid+(objs[i].value)+",";
			
		}	
	}	
   
	if(nid==""){
	alert("请选择要添加的信息终端");
	return false;
	}else{
	$.ajax({
              type : "post",
              url : doSaveUrl ,
              cache: false,
              data : "machinesString=" + nid + "&idandusername="+'<%=request.getAttribute("idname")%>',
              dataType:"json",
              success : function(data){  
              //alert(data);
              if( data== "1" )
               {
                   alert("操作成功");
                   parent.window.location.reload();
                }
               else
               {
                   alert("操作失败");
                   parent.window.location.reload();
               }
              },
              error: function(){alert("服务器没有数据返回，可能服务器忙，请重试");}
           });
	
	}

	
}

</script>


	</head>
	<body style="overflow-x: hidden">

		<!-- 标题 -->
		<div class="mTitle">
			<span class="hidsearch"><a href="javascript:void(0)"
				onClick="return chg('searchList');" id="ImgArrow"> <img
						src="${ctx}/images/icon_up.gif" id="imgButton" />
			</a> </span>
			<b class="bbig">信息终端类型选择</b>
			
		</div>

		<!--list -->
		<div class="searchBar" id="searchList" style="display: block;">
			<form action="/base/userMachineTypeAction!doMyMachineTypeList.ts" method="post" name="form1">
			
				<table class="searchTable">
					<tr>
						<th>
							名称：
						</th>
						<td>
							<s:textfield name="name" theme="simple"></s:textfield>
						</td>
						<th>类型</th>
						<td>
							<s:select
                                 theme="simple"
                                 name="optionId"
                                 list="#request.list" 
                                 cssStyle="width:99px;"	
                                 listKey="optionId"			
                                 listValue="name"					          	
                			     headerKey=""
                                 headerValue="--请选择类型--"		
                			     id="select"/>
							
						</td>
						
						
						<td>
							<input name="btn_query" type="button" class="btn" value="查询"
								onclick="doQuery()" />
							
						</td>
						<td>
							<input name="btn_query" type="button" class="btn" value="接入"
								onclick="doSave()" />
							
						</td>
						<td>
							<input name="btn_query" type="button" class="btn" value="关闭"
								onclick="onCancel()" />
							
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div class="mainList">

			<table class="listTable">
				<tr>
					<th><input type="checkbox" name="checkbox" onclick="checkAll('checkbox',this)"/>选择</th>
					<th>
						名称
					</th>
					
					<th>
						类型
					</th>
					
				</tr>
				
				<c:forEach var="userMachineType" varStatus="status" items="${pager.data}">
					<tr align=center>
						<td><input type="checkbox" name="checkbox" value="${userMachineType.theIdMachine }-${userMachineType.userId }" id="${userMachineType.theIdMachine }"/> </td>
						
						<td>
							${userMachineType.name}
						</td>
						
						<td>
							${userMachineType.optionName }
						</td>
						
						
						
					</tr>
				</c:forEach>

			</table>
		</div>
		<!--end list -->

		<!-- 分页区域  -->
<%@ include file="/page/pager.jsp"%>

<script type="text/javascript">
ajaxAnywhere.formName = "form1";
ajaxAnywhere.getZonesToReload = function() {
    return "zoneList";
}
</script>

	</body>
</html>
